package chpt03;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class CommonClassUsageTest {

	public static void main(String[] args) {
		final int seed = 5, length = 10, low = 1, high = 100;
		
		int[] arr = {5,3,7,1,0,8};
		Arrays.sort(arr);
		System.out.println(Arrays.toString(arr));
		int index = Arrays.binarySearch(arr, 8);
		System.out.println("index = "+index);
		Arrays.fill(arr, 0);
		System.out.println(Arrays.toString(arr));
		

	}

	/**
	 *   使用种子seed返回一个长度为length，值在begin与end(不包括)之间的int数组
	 * @param length 所要生成的数组长度
	 * @param low  随机生成值的下界
	 * @param high 随机生成值的上界
	 * @param seed 种子
	 * @return
	 */
	private static int[] generateIntArr(int length, int low, int high, int seed) {
		int[] arr = new int[length];
		Random rnd = new Random(seed); // 设置种子，每回都产生同样的随机数序列
		for (int i = 0; i < arr.length; i++) {
			arr[i] = low + rnd.nextInt(high);
		}
		return arr;
	}

}
